﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

namespace _5E.Utils.DbHelper
{
    /// <summary>
    /// 程序说明：数据库接口
    /// 创建作者：ahl
    /// 创建时间：2012-03-25
    /// </summary>
    public interface IDb<TConnection, TCommand, TParameter, TDataAdapter>
    {
        #region ExecuteNonQuery

        Int32 ExecuteNonQuery(string sql, CommandType cmdType = CommandType.Text, TParameter[] dbParameters = null, string connectionStr = null);

        #endregion

        #region ExecuteBatchNonQuery

        void ExecuteBatchNonQuery(Dictionary<string, List<DbParameter[]>> batch, string connectionStr = null);

        #endregion

        #region ExecuteScalar

        object ExecuteScalar(string sql);

        object ExecuteScalar(string sql, TParameter[] dbParameters);

        object ExecuteScalar(string sql, CommandType cmdType, TParameter[] dbParameters);

        object ExecuteScalar(string connectionStr, string sql);

        object ExecuteScalar(string connectionStr, string sql, TParameter[] dbParameters);

        object ExecuteScalar(string connectionStr, string sql, CommandType cmdType, TParameter[] dbParameters);

        #endregion

        #region ExecuteDataReader

        DbDataReader GetDataReader(string sql);

        DbDataReader GetDataReader(string sql, TParameter[] dbParameters);

        DbDataReader GetDataReader(string sql, CommandType cmdType, TParameter[] dbParameters);

        DbDataReader GetDataReader(string connectionStr, string sql);

        DbDataReader GetDataReader(string connectionStr, string sql, TParameter[] dbParameters);

        DbDataReader GetDataReader(string connectionStr, string sql, CommandType cmdType, TParameter[] dbParameters);

        #endregion

        #region DataTable

        DataTable GetDataTable(string sql);

        DataTable GetDataTable(string sql, TParameter[] dbParameters);

        DataTable GetDataTable(string sql, CommandType cmdType, TParameter[] dbParameters);

        DataTable GetDataTable(string connectionStr, string sql);

        DataTable GetDataTable(string connectionStr, string sql, TParameter[] dbParameters);

        DataTable GetDataTable(string connectionStr, string sql, CommandType cmdType, TParameter[] dbParameters);

        #endregion

        #region 其他

        TConnection GetConnection(string connectionStr);

        #endregion
    }
}
